package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {


    /**
     * 通过手机号码查找用户
     * @param phone
     * @return
     */
    @Select("select * from user where phone =#{phone}")
    User findUserByPhone(String phone);

    /**
     * 新增用户
     * @param user
     * @return
     */
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    @Insert("insert into user(phone,status) values (#{phone},#{status})")
    void addUser(User user);

    /**
     * 通过用户id查找用户
     * @param id
     * @return
     */
    @Select("select * from user where id=#{id}")
    User findUserById(Long id);

}
